<style type="text/css">
    #home.container{
        background: #fff;
        border-bottom-left-radius: 10px;
        border-bottom-right-radius: 10px;
        border-left: 1px solid #e0e0e0;
        border-right: 1px solid #e0e0e0;
        border-bottom: 1px solid #e0e0e0;
        min-height: 550px;
    }
</style>
<?php
$this->doctype(Zend\View\Helper\Doctype::XHTML1_RDFA);
/** facebook open graph */
$this->headMeta()->appendName('Description', DEFAULT_DESCRIPTION );
$this->headMeta()->appendName('keywords',DEFAULT_KEYWORD );



$search_val = $this->search_val;
$view = $this->view;
$translator = \Velacolib\Utility\Utility::translate();
isset($_GET['search_cat']) ? $search_cat = $_GET['search_cat']  : $search_cat = 0;
isset($_GET['search_loc']) ? $search_loc = $_GET['search_loc']  : $search_loc = 0;
isset($_GET['search_type']) ? $search_type = $_GET['search_type']  : $search_type = '';
isset($_GET['view']) ? $view = $_GET['view']  : $view = '';
$utility = new \Velacolib\Utility\Utility();

?>


<div class="page-header " id="banner">
    <form action="/" method="get" name="search_form" >
        <div class="row" style="">
            <input type="hidden" name="view" value="<?=$view?>" />
            <div class="col-lg-4 col-sm-4 col-md-4" style="margin-top: 5px">
                <input id="search-input" type="text" name="search_val" class="form-control" placeholder="<?=$translator->translate('search_text')?>" />
                <div class="loading_absolute"> &nbsp </div>
            </div>
            <div class="col-lg-4 col-sm-4 col-md-4" style="margin-top: 5px">
                <select class="form-control" name="search_cat">
                    <option value="0"><?=$translator->translate('all')?></option>
                    <?php $cat = Velacolib\Utility\Utility::getCategoryArray(); ?>
                    <?php foreach($cat as $key_cat=>$val_cat){    ?>
                        <option <?php if($search_cat == $val_cat->id) {echo "selected='selected'"; } ?> value="<?php echo $val_cat->id ?>"><?php echo $val_cat->title ?></option>
                    <?php } ?>
                </select>
            </div>
            <div class="col-lg-4 col-sm-4 col-md-4" style="margin-top: 5px">
                <div class="input-group">
                    <select class="form-control" name="search_loc">
                        <?php $loc = Velacolib\Utility\Utility::getLocationArray(); ?>
                        <?php foreach ($loc as $k=>$c) { ?>
                            <option <?php if($search_loc == $k) {echo "selected='selected'"; } ?> value="<?php echo $k ?>"><?php echo $c ?></option>
                        <?php } ?>
                    </select>
                    <span class="input-group-btn">
                      <button class="btn btn-primary btn_purple" id="send" value="Tìm" type="submit"><?=$translator->translate('Search')?></button>
                    </span>
                </div>

            </div>
        </div>
        <div class="row" style="margin: 10px">
            <label class="checkbox-inline">
                <input  type="radio" <?php if($search_type == 0) {echo "checked"; } ?> name="search_type" id="inlineCheckbox2" value="0"/> <?=$translator->translate('Sell')?>
            </label>
            <label class="checkbox-inline">
                <input  type="radio" <?php if($search_type == 1) {echo "checked"; } ?> name="search_type" id="inlineCheckbox1" value="1"/> <?=$translator->translate('Buy')?>
            </label>

        </div>
    </form>
</div>
<div class="content-body">
<div class="row">
    <div class="col-lg-8 col-sm-8 col-md-8">
        <div class="vela-sort-item ">
            <a href="?view=grid"><i class="glyphicon glyphicon-th" title="Xem dạng lưới"></i></a>
            <a href="?view=list"><i class="glyphicon glyphicon-th-list" title="Xem dạng danh sách"></i></a>
        </div>
       <?php if($result): ?>

        <?php foreach ($data as $item): ?>
            <div class="row vela-topic-item">
                <div class="col-lg-3 col-sm-3 col-md-3  topic-image hidden-xs">
                  <a href="/raovat/chitiet/<?php echo $item->slug ?>/<?=$item->id?>">
                    <img title="<?php echo $item->title ?>" alt="<?php echo $item->title ?>" src="/img/blank.gif" data-echo="<?php echo $item->thumb;  ?>"  />
                     </a>
           <!-- $utility::getImageBase64String($_SERVER['DOCUMENT_ROOT'].$item->thumb) -->
                </div>
                <div class="col-lg-9 col-sm-9 col-md-9">
                    <div class="topic-title">
                       <h1 class="h1_title">
                     <a href="/raovat/chitiet/<?php echo $item->slug ?>/<?=$item->id?>">
                            [ <?php echo Velacolib\Utility\Utility::getProductType($item->topic_type); ?> ]
                            <?php echo $item->title; ?></a>
                       </h1>
                    </div>
                    <div class="topic-info">
                        <span class="price">
                            <?php
                              $price = $utility::showPrice($item->price,$item->show_price);
                            echo $price;
                          ?>

                        </span>
                        <span class="time pull-right"><?php echo Velacolib\Utility\Utility::time_stamp($item->create_date); ?></span>
                    </div>
                    <div class="category">
                        <a class="text-info" href="/?search_loc=<?php echo $item->topic_location; ?>">  <?php echo Velacolib\Utility\Utility::getLocationArray($item->topic_location); ?></a>
                        <?php if ($item->cat_id) { ?>
                            <a class="text-info" href="/?search_cat=<?php echo $item->cat_id; ?>"> - <?php $topic_cat = Velacolib\Utility\Utility::getTopicCat()->getCategories($item->cat_id);
                                echo $topic_cat->title; ?></a>
                        <?php } ?>
                    </div>
                </div>
            </div>
        <?php endforeach ?>


        <!-- topic item -->
        <!--paginator -->
        <div class="row vela-col">
            <div class="col-lg-8 col-md-8 col-sm-8">
                 <div class="row">
                <?php
                // add at the end of the file after the table
                echo $this->paginationControl(
                // the paginator object
                    $data,
                    // the scrolling style; see http://zf2.readthedocs.org/en/release-2.1.4/modules/zend.paginator.usage.html#rendering-pages-with-view-scripts
                    'sliding',
                    // the partial to use to render the control
                    array('partial/paginator.phtml', 'index'),
                    // the route to link to when a user clicks a control link
                    array(
                        'route' => 'home',
                        'child_route' => array(
                            'controller' => 'index',
                            'action' => 'index',
                        ),
                        'search_val' => $search_val
                    )
                );
                ?>
                 </div>

                <div class="col-lg-4 col-md-4 col-sm-4">
                  <div class="select_item_per_page">
                      <form action="/" method="get">
                          <?php
                          //unset($search_val['view']);
                          foreach($search_val as $s=>$sk){  ?>
                              <input type="hidden" name="<?php echo $s ?>" value="<?php echo $sk ?>"/>
                          <?php }
                          ?>
                          <?=$translator->translate('Topics/pages')?>
                      <select name="ipg" id="ipg" onchange="this.form.submit()">
                          <option value="50">50</option>
                          <option <?php if ($ipg == 100) echo "selected='selected'"; ?> value="100">100</option>
                          <option <?php if ($ipg == 150) echo "selected='selected'"; ?> value="150">150</option>
                      </select>
                      </form>
                  </div>
                </div>
            </div>


        </div>

        <!--end paginator -->
       <?php  endif ?>
        <?php if($result == false): ?>

             <div class=" alert alert-danger alert-dismissable  ">
                 <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
        Không có kết quả nào phù hợp với từ khóa:  <b> <?= $search_val['search_val'] ?> </b> . Vui lòng tìm kiếm với từ khóa khác!

             </div>
        </div>
        <?php endif ?>

    <!-- list item index -->

    <div class="col-lg-4 col-sm-4 col-md-4 hidden-xs" style="">
       <!-- <iframe src="http://khuyenmaivang.vn/view-banner/right-5giay" marginwidth="0" border="0" scrolling="no" frameborder="0" width="200" height="612"></iframe>
        <iframe src="http://khuyenmaivang.vn/view-banner/right-5giay" marginwidth="0" border="0" scrolling="no" frameborder="0" width="200" height="612"></iframe>     -->
    </div>
    <!-- sidebar right -->

</div>

</div>